<?php
set_time_limit(0);
dl("php_sdl.dll");

define('APP_TITLE', '12 - Drawing primitives');

// Start SDL engine with VIDEO submodule
if(SDL_Init(SDL_INIT_VIDEO) < 0) {
	trigger_error('SDL can not be initialized. Exiting.');
	exit(1);
}

// Create a Window of 640x480, 8 bits of depth
$screen = SDL_SetVideoMode(640, 480, 8, SDL_HWSURFACE);
if(is_null($screen)) {
	trigger_error('Unable to create a new Window with the desired arguments.');
	exit(1);
}

SDL_WM_SetCaption(APP_TITLE, APP_TITLE);

$color = SDL_MapRGB($screen['format'], 200, 100, 20);
SDL_FillRect($screen, array(
	'x' => 0,
	'y' => 0,
	'w' => 640,
	'h' => 480
	), $color);

$color = SDL_MapRGB($screen['format'], 255, 255, 255);

for($i = 50; $i < 100; $i++)
	gfx_aacircleColor($screen['handle'], 640 >> 1, 480 >> 1, $i, $color);

SDL_Flip($screen);

// Wait till' the user press a mouse button
$quit = false;
while(!$quit) {
	SDL_WaitEvent(&$event);
	switch($event['type']) {
		case SDL_KEYDOWN:
		case SDL_MOUSEBUTTONDOWN:
		case SDL_QUIT:
			$quit = true;
			break;
	}

	SDL_Delay(10);
}

// Stop SDL engine
SDL_Quit();

?>
